package JavaSE.d2;

import java.util.Scanner;
//获取绝对值方法
public class Test20 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入一个数");
        System.out.println(abs(scanner.nextInt()));
    }
    private static int abs(int num){
        if(num>0){
            return num;
        }else if (num==0){
            return 0;
        }else {
            return -num;
        }
    }
}
